﻿/**
 * @author Administrator
 */
/**
 * 打开部门添加的模态窗口
 */
function openAddSection(){
    window.showModalDialog('AddOpendBound.aspx', window, 'status:no;center:yes;scroll:0;resizable:no;help:no;dialogWidth:430px;dialogHeight:400px');
}

/**
 * 向父窗口中添加部门
 * @param {Object} val
 * @param {Object} sid
 */
function addSectionToParent(val, sid){
    try {
        var str = window.dialogArguments.document.form1.TxtSections.value;
        var sids = window.dialogArguments.document.form1.HidSids.value;
        if ((str.indexOf(val + ",") > 0 || str.indexOf(val + ",") == 0) &&
        (sids.indexOf(sid + ",") > 0 || sids.indexOf(sid + ",") == 0)) {
            str = str.replace(val + ",", "");
            sids = sids.replace(sid + ",", "");
        }
        else {
            str += (val + ",");
            sids += (sid + ",");
        }
        window.dialogArguments.document.form1.TxtSections.value = str;
        window.dialogArguments.document.form1.HidSids.value = sids;
    } 
    catch (ex) {
        alert(ex.message);
    }
}

/**
 * 添加当前所有部门
 */
function add_all(){
    try {
        var str = "";
        var sids = "";
        for (var i = 0; i < document.all.length; i++) {
            if (document.all[i].s_id != null) {
                str += (document.all[i].innerText + ",");
                sids += (document.all[i].s_id + ",");
            }
        }
        window.dialogArguments.document.form1.TxtSections.value = str;
        window.dialogArguments.document.form1.HidSids.value = sids;
    } 
    catch (ex) {
        alert(ex.message);
    }
}

/**
 * 添加所有部门
 */
function add_all_Section(){
    window.dialogArguments.document.form1.TxtSections.value = "所有部门";
    window.dialogArguments.document.form1.HidSids.value = "0";
}

/**
 * 删除所有部门
 */
function del_all(){
    window.dialogArguments.document.form1.TxtSections.value = "";
    window.dialogArguments.document.form1.HidSids.value = "";
}

/**
 * 隐藏或显示新建通知表格
 * @param {Object} target
 */
function hidTable(target){
    var myTb = document.getElementById(target);
    if (myTb.style.display == "none") {
        myTb.style.display = "inline";
    }
    else {
        myTb.style.display = "none";
    }
    return false;
}

/**
 * 隐藏上传文件框，显示loading
 */
function hidUpload(){
    document.getElementById("upload").style.display = "none";
    document.getElementById("loading").style.display = "inline";
}

/**
 * 判断删除上传附件是否选中
 * @param {Object} target
 */
function checkDelFile(target){
    try {
        var myfile = document.getElementById(target);
        state = false;
        if (myfile.options.length == 0) {
            alert("没有上传的附件！");
        }
        else {
            for (var i = 0; i < myfile.options.length; i++) {
                if (myfile.options[i].selected == true) {
                    state = true;
                }
            }
            if (state == false) {
                alert("请选中您要删除的附件");
            }
        }
    } 
    catch (ex) {
        alert(ex.message);
    }
    return state;
}

/**
 * 选择所有上传附件并验证
 */
function selectAllAffixFile() {
/**
    var myop = document.getElementById("ListBox1");
    for (i = 0; i < myop.options.length; i++) {
        myop.options[i].selected = true;
    }
    **/
    if (document.getElementById("HidSids").value == "") {
    	alert("请选择通告开放范围！");
		return false;
    }
    if (document.getElementById("TxtTitle").value == "") {
        alert("请填写标题！");
        return false;
    }
    if (document.getElementById("<%=MyEditor.ClientID%>").value == "") {
        alert("内容不能为空！");
        return false;
    }
    if (document.getElementById("TxtStart").value == "") {
        alert("请输入开始日期！");
        return false;
    }
    if (document.getElementById("TxtEnd").value == "") {
        alert("请输入结束日期！");
        return false;
    }
    return true;
}
